<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * Mall
 */
namespace Mall\Controller;
use Common\Controller\AdminController;
Vendor('Qiniusdk.autoload'); //七牛入口文件引入 
use Qiniu\Auth; 
use Qiniu\Storage\UploadManager;
use Think\Upload;
/**
 * 页面
 */
class PageController extends AdminController{
	
	/**
	 * 单曲管理
	 */
    public function Manage(){

		common_public()->assign_page('菜单管理');
		
		//上传开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and'); 
			
		}else{
			
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			
			$map['name'] = array('like',"%$name%");

		}
		$this->assign('name',$name);
		
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';

		if($uid!=0){
			
			$map['uid'] =array('like',"%$uid%");
		}
		
		//selected="selected"
		$this->assign('uid',$uid);
		
		
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$m_cms_content = M('cms_content');
		$m_common_user = M('common_user');
		
		//获得上级信息
		$fmap['id'] = I('param.form_id')?I('param.form_id'):0;
		$fmap['type'] = get_cms_model_conf('CMS_PAGE');
		$fmap['status'] = 1;
		
		$data = $m_cms_content->where($fmap)->find();
		
		$search = I('param.search');
		//判断是否是搜索
		if(!$search){
			
			$map['form_id'] = $fmap['id'];
			
		}
		
		$map['type'] = get_cms_model_conf('CMS_PAGE');
		$map['status'] = 1;
		
		
		$list = $m_cms_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_cms_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			
			
			$umap['id'] = $list[$i]['uid'];
			
			$udata = $m_common_user->where($umap)->find();
			
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
		
		}
		//赋值
		$this->assign('list',$list);
		$this->assign('data',$data);
		$this->assign('form_id',$fmap['id']);
		
		
		$this->display();
	}
	
	/**
	 * 新增页面
	 */
	public function Create(){
		//判断是否是ajax请求 
		/* $accessKey = '8sc_uncdqBnQUYyWViRALobZH33YO_lZKD65Y04a';
		$secretKey = 'FczTgs6OmHBb7jke7pExGeujvxIHXO0trUCIbmBE';
		$auth = new Auth($accessKey, $secretKey);
		$bucketName = 'music';
		$token = $auth->uploadToken($bucketName); */
		
		$m_mall_content = M("mall_content");
		$m_cms_style = M("cms_style");
		$m_mall_content_img = M("mall_content_img");
		include_once 'upload.func.php';
		if(IS_POST){
			//获得数据
			$files = $_FILES['color_img']; 
			foreach($files as $i=>$v){
				foreach($files[$i] as $ii=>$vv){
					$files_list[$ii][$i] = $files[$i][$ii];
				}
			}
			$files = $files_list;
			
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			
			/* foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			} */
			
			
			$data = I();
			$style = $data['style'];
			$data['value'] = I('param.value','','');
			if($style){
				$data['style'] = implode(',',$data['style']);
			}
			$data['uid'] = getUID();
			$data['type'] = get_mall_model_conf('MALL_SINGLE');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$data['status'] = 2;
			/* dump($data);
			dump($uploadFiles);
			die; */
			$result = $m_mall_content->add($data);
			if($result){
				foreach($uploadFiles as $i=>$v){
					$img_name_list = explode("/",$uploadFiles[$i]);
					$count = count($img_name_list);
					$str_str = substr($uploadFiles[$i],1);
					
					upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
					mall_img(1,$result,trim($uploadFiles[$i],'.'));
				}
			}
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(1,$result,$style); 
				
				$this->success('新增成功', U('Mall/Page/Create'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
				$this->error('新增失败');
			}	
		}else{
			#查询语言
			$langue_list = getlangeues();
			#查询流派风格
			$style_list = gettypes();
			/* $this->assign("token",$token); */
			$this->assign("langue_list",$langue_list);
			$this->assign("style_list",$style_list);
			$this->display();
		}
		
	
	}
	
	/**
	 * 页面详情
	 */
	public function Detail(){
    
		$m_cms_content = M('cms_content');
		
		common_public()->assign_page('页面详情');
		
		$map['id'] = I('param.id');
		$map['type'] = get_cms_model_conf('CMS_PAGE');
		$map['status'] = 1;
			
		$data = $m_cms_content->where($map)->find();
			
		$this->assign('data',$data);
		
			
		$this->display();
		
		
	
	}
	
	/**
	 * 编辑歌曲
	 */
	public function Edit_song(){
    
		$m_mall_content = M('mall_content');
		
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			//获得数据
			
			$data = I('');
			unset($data['id']);
			$style = I('param.style');
			$data['style'] = implode(',',I('param.style'));
			$data['value'] = I('param.value','','');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']  
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(1,$map['id'],$style); 
				$this->success('编辑成功', U('Mall/Page/Song'));
			
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
			
				$this->error('编辑失败');
			
			}
		
		}else{
			#查询语言
			$langue_list = getlangeues();
			#查询流派风格
			$style_list = gettypes();
			#详情
			$map['type'] = get_mall_model_conf('MALL_SINGLE');
			$map['status'] = array("in",'2,4');
			$map['uid'] = getUID();
			$data = $m_mall_content->where($map)->find();
			$style_list = if_style($style_list,$data['style']);
			
			$this->assign('langue_list',$langue_list);
			$this->assign('style_list',$style_list);
			$this->assign('data',$data);
			
			$this->display();
		}
	}
	
	/**
	 * 编辑歌曲
	 */
	public function Edit_all_song(){
    
		$m_mall_content = M('mall_content');
		
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			$data = I('');
			$style = I('param.style');
			unset($data['id']);
			$data['style'] = implode(',',$style);
			$data['value'] = I('param.value','','');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(1,$map['id'],$style); 
				
				$this->success('编辑成功', U('Mall/Page/all_song'));
			
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
			
				$this->error('编辑失败');
			
			}
		
		}else{
			#查询语言
			$langue_list = getlangeues();
			#查询流派风格
			$style_list = gettypes();
			#详情
			$map['type'] = get_mall_model_conf('MALL_SINGLE');
			$map['status'] = array("in",'1,2,3,4');
			$data = $m_mall_content->where($map)->find();
			
			$style_list = if_style($style_list,$data['style']);
			
			$this->assign('langue_list',$langue_list);
			$this->assign('style_list',$style_list);
			$this->assign('data',$data);
			
			$this->display();
		}
	}
	
	/**
	 * 批量改变页面状态
	 */
	public function Delete($id,$status=0){
		
	
		//判断是否是ajax请求
		if(IS_AJAX){
				
			$m_mall_content = M('mall_content');
			
			$id = $id?$id:I('param.id');
			$status = $status?$status:I('param.status');
			
			if($id){
				
			
				$id = explode(',',$id); 
				
				
				foreach($id as $i=>$k){
					
					
					$map['id'] = $id[$i];
					$data['status'] = $status;
					
					$m_mall_content->where($map)->save($data);
					
				}
				
				//返回信息
				$info = get_errcode(0);
			
			}else{
				
				$info = get_errcode(10000001);
			}
			
	
		
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);


	}
	
	
	
	/**
	 * 页面管理
	 */
    public function banner(){

		//页面配置
		$page = array(
			'title'=>'页面管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		$this->assign('page',$page);
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		
		//判断是否搜索标题
		$name = I('param.name');
		if($name){
			
			$map['name'] = array('like',"%$name%");

		}
		$this->assign('name',$name);
		
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';

		if($uid!=0){
			
			$map['uid'] =array('like',"%$uid%");
		}
		
		//selected="selected"
		$this->assign('uid',$uid);
		
		
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$m_cms_content = M('cms_content');
		$m_common_user = M('common_user');
		
		//获得上级信息
		$fmap['id'] = I('param.form_id')?I('param.form_id'):0;
		$fmap['type'] = get_cms_model_conf('CMS_PAGE');
		$fmap['status'] = 1;
		
		$data = $m_cms_content->where($fmap)->find();
		
		$search = I('param.search');
		//判断是否是搜索
		if(!$search){
			
			$map['form_id'] = $fmap['id'];
			
		}
		$map['type'] = get_cms_model_conf('CMS_PAGE');
		$map['status'] = 1;
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_cms_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_cms_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			
			
			$umap['id'] = $list[$i]['uid'];
			
			$udata = $m_common_user->where($umap)->find();
			
			$map_num['form_id'] = $list[$i]['id'];
			$map_num['type'] = get_cms_model_conf('CMS_PAGE');;
			$map_num['status'] = 1;
			$list[$i]['num'] = $m_cms_content->where($map_num)->count();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
		
		}
		//赋值
		$this->assign('list',$list);
		$this->assign('data',$data);
		$this->assign('form_id',$fmap['id']);
		
		
		$this->display();
	}
	
	/**
	 * 页面管理
	 */
    public function Song(){

		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['uid'] = getUID();
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	
	
	/**
	 *单曲管理
	 */
    public function all_song(){
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';

		if($uid!=0){
			
			$map['uid'] =array('like',"%$uid%");
		}
		$this->assign('uid',$uid);
		
		//判断是否搜索名称
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			$list[$i]['style'] = style_str($list[$i]['style']);
			
		}
		//dump($list);die;
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		$this->display();
	}
	
	/**
	 *单曲管理
	 */
    public function no_song(){
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';

		if($uid!=0){
			
			$map['uid'] =array('like',"%$uid%");
		}
		$this->assign('uid',$uid);
		
		//判断是否搜索名称
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = array("in",'3');
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style_name']);
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		
		$this->display();
	}
	
	
	/**
	 * 推荐管理
	 */
    public function tui_song(){
		//页面配置
		$page = array(
			'title'=>'推荐管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';

		if($uid!=0){
			
			$map['uid'] =array('like',"%$uid%");
		}
		$this->assign('uid',$uid);
		
		//判断是否搜索名称
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = array("in",'1');
		$map['recommended'] = array("in",'1');
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style_name']);
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		
		$this->display();
	}
	
	
	/**
	 *活动列表 
	 */
    public function Activity(){

		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		//页面配置
		$page = array(
			'title'=>'活动列表',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
		$map['uid'] = getUID();
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_mall_content ->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content ->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$style_name = array();
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style']);
		
		}
		
		//dump($list);die;
		//赋值
		$this->assign('list',$list);
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	/* 专辑歌曲管理 */
	public function album_song(){
		
		$this->display();
	}
	
	/* 新增歌曲 */
	public function music_create(){
		
		$this->display();
	}
	
	
		
	/* 新增活动 */
	public function create_activity(){
		include_once 'upload.func.php';
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$files = getFiles(); 
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			/* dump($files);  
			dump($uploadFiles);die; */
			foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				//dump($str_str);die;
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				//dump($img_name_list[$count - 1]);
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			}
			
			//获得数据
			$data = I();
			$data['img'] = $str;
			$style = I('param.style');
			$data['style'] = implode(',',I('param.style'));
			$data['value'] = I('param.value','','');
			$data['uid'] = getUID();
			$data['type'] = get_mall_model_conf('MALL_ACTIVITY');
			$data['time'] = time();
			$data['release_time'] = strtotime(I("param.release_time"));
			$data['ip'] = get_client_ip();
			$data['status'] = 2;
			$result = $m_mall_content->add($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(3,$result,$style); 
				
				$this->success('新增成功', U('Mall/Page/activity'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
				$this->error('新增失败');
			}	
		}else{
			
			#查询流派风格
			$style_list = gettypes();
			
			/* $this->assign("token",$token); */
			$this->assign("style_list",$style_list);
			$this->display();
		}
	}
	
	/* 管理全部歌曲 */
	public function all_album_song(){
		
		$this->display();
	}
	
	
	/* 管理全部活动  */
	public function all_activity(){
		
		//页面配置
		$page = array(
			'title'=>'活动列表',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';
		if($uid!=0){
			$map['uid'] =array('like',"%$uid%");
		}
		//selected="selected"
		$this->assign('uid',$uid);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
		$map['status'] = array("in",'1,2,3,4');
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_mall_content ->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content ->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//dump($list );die;
		//查询关联信息
		foreach($list as $i=>$k){
			
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style']);
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	/* 管理全部活动  */
	public function tui_activity(){
		
		//页面配置
		$page = array(
			'title'=>'活动列表',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';
		if($uid!=0){
			$map['uid'] =array('like',"%$uid%");
		}
		$this->assign('uid',$uid);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
		$map['status'] = array("in",'1');
		$map['recommended'] = array("in",'1');
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_mall_content ->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content ->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//dump($list );die;
		//查询关联信息
		foreach($list as $i=>$k){
			
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style']);
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	/* 排序单曲推荐位置 */
	public function r_activity(){
		$m_mall_content = M('mall_content');
		if(IS_AJAX){
			
			$map['id'] = I("param.id");
			$data['sort'] = I("param.sort");
			if(!empty($map['id'])){
				$result = $m_mall_content->where($map)->save($data);
				if($result){
					$info = 1;
				}else{
					$info = 2;
				}
			}else{
				$info = 3;
			}
			
		}else{
			$info = 4;
		}
		$this->ajaxReturn($info);
	}
	
	
	
	/* 管理全部活动  */
	public function no_activity(){
		
		//页面配置
		$page = array(
			'title'=>'活动列表',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//用户UID
		$uid = I('param.uid')?I('param.uid'):'';
		if($uid!=0){
			$map['uid'] =array('like',"%$uid%");
		}
		$this->assign('uid',$uid);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
		$map['status'] = 3;
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_mall_content ->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content ->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//dump($list );die;
		//查询关联信息
		foreach($list as $i=>$k){
			
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style_name']);
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	/* 管理推荐活动 */
	public function Best_activity(){
		
		$this->display();
	}
	
	/* 管理推荐单曲 */
	public function Best_song(){
		
		$this->display();
	}
	
	
	/* 编辑活动 */
	public function Edit_activity(){
		$m_mall_content = M('mall_content');
		include_once 'upload.func.php';
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			
			$files = getFiles(); 
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			/* dump($files);  
			dump($uploadFiles);die; */
			foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				//dump($str_str);die;
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				//dump($img_name_list[$count - 1]);
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			}
			
			$data = I('');
			$style = I("param.style");
			$data['img'] = $str;
			unset($data['id']);
			$data['style'] = implode(',',$style);
			$data['value'] = I('param.value','','');
			$data['release_time'] = strtotime(I("param.release_time"));
			$data['ip'] = get_client_ip();
			
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(3,$map['id'],$style); 
				$this->success('编辑成功', U('Mall/Page/activity'));
			
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
			
				$this->error('编辑失败');
			
			}
		
		}else{
			
			$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
			$map['status'] = array('in','2,4');
			$map['uid'] = getUID();
			$data = $m_mall_content->where($map)->find();
			#流派风格
			$style_list = gettypes();
			
			$style_list = if_style($style_list,$data['style']);
			//dump($style_list);die;
			
			$this->assign('data',$data);
			$this->assign('style_list',$style_list);
			$this->display();
		}
	}
	
	
	/* 管理员编辑活动 */
	public function Edit_all_activity(){
		$m_mall_content = M('mall_content');
		include_once 'upload.func.php';
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			
			$files = getFiles(); 
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			/* dump($files);  
			dump($uploadFiles);die; */
			foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				//dump($str_str);die;
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				//dump($img_name_list[$count - 1]);
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			}
			
			$data = I('');
			$data['img'] = $str;
			$style = I("param.style");
			unset($data['id']);
			$data['style'] = implode(',',$style);
			$data['value'] = I('param.value','','');
			$data['release_time'] = strtotime(I("param.release_time"));
			$data['ip'] = get_client_ip();
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				#创建单曲与风格的关联  zyd_cms_style 
				add_style(3,$map['id'],$style);
				$this->success('编辑成功', U('Mall/Page/All_activity'));
			
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
			
				$this->error('编辑失败');
			
			}
		
		}else{
			
			$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
			$map['status'] = array('in','1,2,3,4');
			$data = $m_mall_content->where($map)->find();
			#流派风格
			$style_list = gettypes();
			
			$style_list = if_style($style_list,$data['style']);
			$this->assign('data',$data);
			$this->assign('style_list',$style_list);
			$this->display();
		}
	}
	
	#加入推荐
	public function recommended($id,$recommended=0){
		//判断是否是ajax请求
		if(IS_AJAX){
			$m_mall_content = M('mall_content');
			
			$id = $id?$id:I('param.id');
			$recommended= $recommended?$recommended:I('param.recommended');
			
			if($id){
				$id = explode(',',$id);
				foreach($id as $i=>$k){
					$map['id'] = $id[$i];
					$data_data = $m_mall_content->where($map)->find();
					if($data_data['status'] == 1){
						$data['recommended'] = $recommended;
						$m_mall_content->where($map)->save($data);
					}
					
				}
				
				//返回信息
				$info = get_errcode(0);
			}else{
				
				$info = get_errcode(10000001);
			}
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
		
	}
	
	
	
	/**
	 * 页面管理
	 */
    public function set_playlist(){
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['uid'] = getUID();
		$map['status'] = 1;
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单列表
		$playlist_map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$playlist_map['uid'] = getUID();
		$playlist_map['status'] = 1;
		$playlist_list = $m_mall_content->where($playlist_map)->select();
		$this->assign('playlist_list',$playlist_list);
		$this->display();
	}
	
	/**
	 * 页面管理
	 */
    public function playlist_details(){
		//页面配置
		$page = array(
			'title'=>'歌单详情',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$details_map['id'] = I("param.id");
		$details_map['status'] = 1;
		$details_map['type'] = 20;
		$details_data = $m_mall_content->where($details_map)->find();
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = 1;
		$map['uid'] = getUID();
		$map['id'] = array("in",$details_data['value']);
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单id
		$this->assign("details_data",$details_data);
		
		$this->display();
	}
	
	
	/**
	 * 歌单列表（音乐人）
	 */
    public function playlist(){
		$m_mall_content = M('mall_content');
		
		//获得菜单信息
		$map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$map['uid'] = getUID();
		$map['status'] = 1;
		$list = $m_mall_content->where($map)->order('sort desc')->select();
		
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	/**
	 * 音乐人歌单列表（管理员）
	 */
    public function musicians_playlist(){
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		$u_map['group_id'] = array("gt",2);
		$u_map['status'] = 1;
		$u_list = $m_common_user->where($u_map)->field("id")->select();
		$u_array = array_column($u_list,"id");
		$u_str = implode(",",$u_array);
		
		//获得菜单信息
		$map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$map['status'] = 1;
		$map['uid'] = array('in',$u_str);
		
		$list = $m_mall_content->where($map)->order('sort desc')->select();
		foreach($list as $i=>$v){
			$user_map['id'] = $list[$i]['uid'];
			$user_data = $m_common_user->where($user_map)->find();
			$list[$i]['username'] = $user_data['nickname'];
		}
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	/**
	 * 新增菜单
	 */
	public function Create_playlist(){
		
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			//获得数据
			$data = I();
			
			$data['uid'] = getUID();
			$data['type'] = get_mall_model_conf('MALL_PLAYLIST');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$data['status'] = 1;
			
			$result = $m_mall_content->add($data);
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	/**
	 * 编辑菜单
	 */
	public function Edit_playlist(){
    
	
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			$map['id'] = I('param.id');
			$map['uid'] = getUID();
			$data = I('');
			unset($data['id']);
		
			$result = $m_mall_content->where($map)->save($data);
			
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	/**
	 * 批量删除菜单
	 */
	public function Delete_playlist($id,$status=0){
		
	
		//判断是否是ajax请求
		if(IS_AJAX){
				
			$m_mall_content = M('mall_content');
		
			$id = $id?$id:I('param.id');
			$status = $status?$status:I('param.status');
			
			if($id){
				$id = explode(',',$id);
				foreach($id as $i=>$k){
					$map['id'] = $id[$i];
					$data['status'] = $status;
					$m_mall_content->where($map)->save($data);
					
				}
				
				//返回信息
				$info = get_errcode(0);
			
			}else{
				
				$info = get_errcode(10000001);
			}
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);
		$this->ajaxReturn($info);
	}
	
	
	/**
	 * 批量加入歌单,取消加入
	 * $id 为加入或者取消ID   $status = 1 为加入  2为取消   $playlist_id 为目标歌单
	 */
	public function add_playlist(){
		
		//判断是否是ajax请求
		if(IS_AJAX){
				
			$m_mall_content = M('mall_content');
		
			$id = I('param.id');
			$status = I("param.status");
			$playlist_id = I("param.playlist_id");
			
			if(!empty($id) and !empty($status) and !empty($playlist_id)){
				$map['id'] = $playlist_id;
				$map['type'] = 20;   //歌单
				$data = $m_mall_content->where($map)->find();
				
				$playlist_array = explode(',',$data['value']);
				$id_array = explode(',',$id);
				if($status == 1){
					#两个数组去重，避免重复
					$array_array = array_keys(array_flip($playlist_array)+array_flip($id_array));
					$save_data['value'] = implode(',',$array_array);
					$save_data['value'] = trim($save_data['value'],',');
					
				}else{
					$array_array = array_diff($playlist_array,$id_array);
					$save_data['value'] = implode(',',$array_array);
				}
				$result = $m_mall_content->where($map)->save($save_data);
				
				//返回信息
				$info = get_errcode(0);
			
			}else{
				
				$info = get_errcode(10000001);
			}
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);
		$this->ajaxReturn($info);
	}
	
	
	/**
	 * 歌单列表（管理员）
	 */
    public function all_playlist(){
		$m_mall_content = M('mall_content');
		
		//获得菜单信息
		$admin_uid = admin_uid();
		$map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$map['status'] = 1;
		$map['uid'] = array("in",$admin_uid);
		$list = $m_mall_content->where($map)->order('sort desc')->select();
		
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	/**
	 * 歌单推荐列表（管理员）
	 */
    public function tui_playlist(){
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		$admin_uid = admin_uid();
		//获得菜单信息
		$admin_uid = admin_uid();
		$map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$map['status'] = 1;
		$map['recommended'] = 1;
		$map['uid'] = array("in",$admin_uid);
		$list = $m_mall_content->where($map)->order('sort desc')->select();
		foreach($list as $i=>$v){
			$u_map['id'] = $list[$i]['uid'];
			$u_data = $m_common_user->where($u_map)->find();
			$list[$i]['username'] = $u_data['nickname'];
		}
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	
	/**
	 * 新增菜单
	 */
	public function all_create_playlist(){
		
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			//获得数据
			$data = I();
			$data['uid'] = getUID();
			$data['type'] = get_mall_model_conf('MALL_PLAYLIST');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$data['status'] = 1;
			
			$result = $m_mall_content->add($data);
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	
	/**
	 * 编辑菜单
	 */
	public function all_edit_playlist(){
    
	
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			$map['id'] = I('param.id');
			
			$data = I('');
			unset($data['id']);
		
			$result = $m_mall_content->where($map)->save($data);
			
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	/**
	 * 页面管理
	 */
    public function all_set_playlist(){
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		#所有管理员的发布 admin_uid();
		$admin_uid = admin_uid();
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = 1;
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单列表   所有管理员创建
		$playlist_map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$playlist_map['uid'] = array("in",$admin_uid);
		$playlist_map['status'] = 1;
		$playlist_list = $m_mall_content->where($playlist_map)->select();
		$this->assign('playlist_list',$playlist_list);
		$this->display();
	}
	
	
	/**
	 * 页面管理
	 */
    public function all_playlist_details(){
		//页面配置
		$page = array(
			'title'=>'歌单详情',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$details_map['id'] = I("param.id");
		$details_map['status'] = 1;
		$details_map['type'] = 20;
		$details_data = $m_mall_content->where($details_map)->find();
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = 1;
		$map['id'] = array("in",$details_data['value']);
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单id
		$this->assign("details_data",$details_data);
		
		$this->display();
	}
	
	/**
	 * 文章管理
	 */
    public function ranking(){

		//页面配置
		$page = array(
			
			'title'=>'排行管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		
		);
		
		$this->assign('page',$page);
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_RANKING');
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('status asc,time desc')->page($_GET['p'].',50')->select();
	
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['n_img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
	public function Create_ranking(){
		$m_cms_content = M("cms_content");
		$m_mall_content = M("mall_content");
		
		if(IS_POST){
			$data = I("");
			
			
			//dump($data);die;
		}else{
			#风格
			$style_map['type'] = get_mall_model_conf('MALL_STYLE');
			$style_map['status'] = 1;
			$style_list = $m_mall_content->where($style_map)->select();
			
			#排行类型
			$rtyle_style_map['type'] = get_cms_model_conf('CMS_RANKING_STYLE');
			$rtyle_style_map['status'] = 1;
			$rtyle_style_list = $m_cms_content->where($rtyle_style_map)->select();
			
			#时间
			$time_map['type'] = get_cms_model_conf('CMS_TIME');
			$time_map['status'] = 1;
			$time_list = $m_cms_content->where($time_map)->select();
			
			#排行的种类  单曲、专辑、音乐人
			$type_map['type'] = get_cms_model_conf('CMS_RANKING_TYPE');
			$type_map['status'] = 1;
			$type_list = $m_cms_content->where($type_map)->select();
			
			$this->assign("style_list",$style_list);
			$this->assign("rtyle_style_list",$rtyle_style_list);
			$this->assign("time_list",$time_list);
			$this->assign("type_list",$type_list);
			$this->display();	
		}
		
	}
	
	public function Create_rankings(){
		$m_cms_content = M("cms_content");
		$m_mall_content = M("mall_content");
		
		if(IS_POST){
			$data = I("");
			
			//dump($data);die;
		}else{
			#风格
			$style_map['type'] = get_mall_model_conf('MALL_STYLE');
			$style_map['status'] = 1;
			$style_list = $m_mall_content->where($style_map)->select();
			
			#排行类型
			$rtyle_style_map['type'] = get_cms_model_conf('CMS_RANKING_STYLE');
			$rtyle_style_map['status'] = 1;
			$rtyle_style_list = $m_cms_content->where($rtyle_style_map)->select();
			
			#时间
			$time_map['type'] = get_cms_model_conf('CMS_TIME');
			$time_map['status'] = 1;
			$time_list = $m_cms_content->where($time_map)->select();
			
			#排行的种类  单曲、专辑、音乐人
			$type_map['type'] = get_cms_model_conf('CMS_RANKING_TYPE');
			$type_map['status'] = 1;
			$type_list = $m_cms_content->where($type_map)->select();
			
			$this->assign("style_list",$style_list);
			$this->assign("rtyle_style_list",$rtyle_style_list);
			$this->assign("time_list",$time_list);
			$this->assign("type_list",$type_list);
			$this->display();	
		}
		
	}
	
	
	
}